package chamster.maeander;

import java.util.List;

import chamster.MaeanderHamster;
import chamster.statemachine.HamsterState;

public class OnceUpInfThanRight extends MaeanderBasicState {

	public List<HamsterState<MaeanderHamster>> applyState(
			List<HamsterState<MaeanderHamster>> states,
			MaeanderHamster hamster) throws Exception {
		if(hamster.canMoveForeward()) {
			hamster.foreward();
			states.add(this);
		} else {
			if(hamster.getView().canMoveRight()) {
				states.add(new RightForewardRight(new OnceDownInfThanLeft()));
			}
			if(hamster.getView().canMoveLeft()) {
				states.add(new LeftForewardLeft(new ForewardShiftRight()));
			}
		}
		return states;
	}

	public boolean isApplicable(MaeanderHamster hamster) {
		return hamster.canMoveForeward()
				|| hamster.getView().canMoveLeft()
				|| hamster.getView().canMoveRight();
	}

}
